home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / pic_tc.zip / DEMOPIC.C next >
Text File  |  1990-05-26  |  6KB  |  158 lines

  1. /*****************************************************************************
  2.  *                                                                           *
  3.  *    DEMOPIC.C    .... A demonstration of the CSH PIC_TC functions          *
  4.  *                      for use with Turbo C                                 *                                        *
  5.  *                                                                           *
  6.  *        NOTE:   Use DEMOPIC.PRJ project make file and compile using        *
  7.  *                the small memory model.                                    *
  8.  *                                                                           *
  9.  *                  PIC is a trademark of LOTUS corporation                  *
  10.  *                  Turbo C is a trademark of BORLAND INTERNATIONAL          *
  11.  *                                                                           *
  12.  *****************************************************************************/
  13.  
  14.  
  15. /*****************************************************************************
  16.  *                    STANDARD C LIBRARY HEADER FILES                        *
  17.  *****************************************************************************/
  18.        #include <stdlib.h>
  19.        #include <conio.h>
  20.        #include <stdio.h>
  21.        #include <string.h>
  22.  
  23. /*****************************************************************************
  24.  *                    CUSTOM PIC ROUTINE PROTOTYPES                          *
  25.  *****************************************************************************/
  26.        #include "pic_tc.h"
  27.  
  28.  
  29. main(){
  30.        int    i;
  31.        char   buffer[10],text[20];
  32.        float  tick=0.15;
  33.  
  34.        /*display title*/
  35.        clrscr();
  36.        gotoxy(1,1);
  37.        printf("----------------------------------------------------------------------------\n");
  38.        printf("Turbo C PIC library demo program\n");
  39.        printf("Version 1.1  Spring 1990\n");
  40.        printf("(c) CSH Services, 1990\n");
  41.        printf("----------------------------------------------------------------------------\n\n");
  42.  
  43.        /*display description of demo*/
  44.        printf("This program will create a file called 'TRY.PIC' on the same drive and\n");
  45.        printf("subdirectory from which the demo is run.  This PIC file will demonstrate\n");
  46.        printf("all of the features of the library and can be viewed with such commercial\n");
  47.        printf("software as Lotus 123 etc.  The PIC file created is approximately 25 kbytes\n");
  48.        printf("in length, so there must be at least this amount of free space on the\n");
  49.        printf("appropriate drive\n\n");
  50.  
  51.        /*option to quit*/
  52.        printf("Press ESC to abort demo...any other key to create TRY.PIC\n\n");
  53.        if(getch()==27){
  54.               printf("Demo aborted...goodbye\n\n");
  55.               return(0);
  56.               }
  57.  
  58.        /*initiation*/
  59.        if(pic_open("try.pic")!=0){
  60.               printf("ERROR in opening file\n");
  61.               printf("Demo aborted...goodbye\n\n");
  62.               return(0);
  63.               }
  64.  
  65.        /*set defaults*/
  66.        printf("File opened OK\n");
  67.        pic_set_sp(100,200,2100,2200);
  68.        pic_set_scale(-10.0,10.0,-10.0,10.0);
  69.        pic_set_font(1);
  70.        printf("....scaling set..");
  71.  
  72.        /*display title*/
  73.        pic_set_cs(1.5,1.5);
  74.        pic_pu_move_abs(0,9);
  75.        pic_draw_text("Demonstration of PIC routines",0,0);
  76.        pic_set_cs(1.0,1.0);
  77.        pic_pu_move_rel(0,-1);
  78.        pic_draw_text("...a test of relative move...",0,0);
  79.        printf("..title drawn....\n");
  80.  
  81.        /*draw 8 blocks in different colours*/
  82.        pic_set_cs(0.32,0.32);
  83.        pic_set_linetype(0);
  84.        for(i=1;i<=8;i++){
  85.               pic_set_colour(i);
  86.               pic_draw_block(4.5,-5+i,5.5,-4+i);
  87.               pic_pu_move_abs(4.25,-4.5+i);
  88.               itoa(i,buffer,10);
  89.               pic_draw_text(buffer,0,0);
  90.               }
  91.        pic_set_cs(0.4,0.4);
  92.        pic_pu_move_abs(4.0,0);
  93.        pic_draw_text("colour codes",3,2);
  94.        printf("....solid blocks drawn..");
  95.  
  96.        /*draw 5 rectangle in different line styles*/
  97.        pic_set_cs(0.5,0.5);
  98.        for(i=0;i<5;i++){
  99.               strcpy(text,"Line type #");
  100.               pic_set_linetype(i);
  101.               pic_draw_rectangle(-7.5+i,-7.5+i,7.5-i,7.5-i);
  102.               pic_pu_move_abs(0,-7.5+i);
  103.               itoa(i,buffer,10);
  104.               strcat(text,buffer);
  105.               pic_draw_text(text,0,4);
  106.               }
  107.        printf("..rectangles drawn....\n");
  108.  
  109.        /*draw circles*/
  110.        for(i=0;i<5;i++){
  111.               pic_set_colour(i+1);
  112.               pic_draw_circle(-6.5+i,6.5-i,1+i);
  113.               }
  114.        pic_set_colour(1);
  115.        printf("....circles drawn..");
  116.  
  117.        /*draw x-axis*/
  118.        pic_set_linetype(0);
  119.        pic_pu_move_abs(-10,-9);
  120.        for(i=-10;i<=10;i++){
  121.               pic_pd_move_abs((float) i,-9);
  122.               pic_pd_move_rel(0,-tick);
  123.               pic_pu_move_rel(0,tick);
  124.               }
  125.        printf("..x-axis drawn....\n");
  126.  
  127.        /*label x-axis*/
  128.        pic_set_cs(0.4,0.4);
  129.        pic_set_colour(3);
  130.        for(i=-10;i<=10;i++){
  131.               pic_pu_move_abs((float) i,-9);
  132.               pic_pu_move_rel(0,-(2*tick));
  133.               itoa(i,buffer,10);
  134.               pic_draw_text(buffer,0,2);
  135.               }
  136.        pic_set_colour(2);
  137.        printf("....x-axis labelled..");
  138.  
  139.        /*draw copywrite notice*/
  140.        pic_set_font(2);
  141.        pic_set_cs(0.9,1.5);
  142.        pic_pu_move_abs(7.7,-7.5);
  143.        pic_draw_text("(c) CSH Services, 1990",1,1);
  144.        printf("..copywrite drawn....\n");
  145.  
  146.        /*finish routine*/
  147.        i=pic_close();
  148.        switch(i){
  149.               case 0: printf("File closed OK\n");break;
  150.               default:printf("ERROR in closing file\n");
  151.               }
  152.        printf("\npress any key...to return to DOS\n\n");
  153.        getch();
  154.        clrscr();
  155.  
  156. return(0);
  157. }
  158.